package com.example.yblin.hello24;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yblin.hello24.DataUtils.GameUtil;

public class ResultActivity extends AppCompatActivity {

    private ImageView btBack;
    private TextView tvResults;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);

        btBack = findViewById(R.id.back_results);
        btBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });

        tvResults = findViewById(R.id.textView_results);
        StringBuilder builder = new StringBuilder();
        for (int i = 1; i <= 10; i++) {
            builder.append("问题" + i + "：").append(GameUtil.numbers[i][0].number + " ")
                    .append(GameUtil.numbers[i][1].number + " ")
                    .append(GameUtil.numbers[i][2].number + " ")
                    .append(GameUtil.numbers[i][3].number + "\n");
            builder.append("正确的表达式有：\n");
            for (String s : GameUtil.answer[i]) {
                s = s.replace('*', '×');
                s = s.replace('/', '÷');
                builder.append(s).append('\n');
            }
            builder.append('\n');
        }
        tvResults.setText(builder.toString());
    }
}